﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using EuroManager.Domain.Simulator.Engine;
using EuroManager.Domain.Simulator.Helpers;

namespace EuroManager.Domain.Simulator.World
{
    public class Clock : ITimeAware
    {
        private static readonly float totalGameTime = (float)TimeSpan.FromMinutes(90).TotalSeconds;

        private float currentTime = 0;
        private float timeFactor;

        public Clock(TimeSpan totalRealTime)
        {
            Contract.Requires(totalRealTime != TimeSpan.Zero);

            timeFactor = (float)(totalGameTime / totalRealTime.TotalSeconds);
        }

        public TimeSpan CurrentTime
        {
            get { return TimeSpan.FromSeconds(currentTime); }
        }

        public void Update(float elapsedTime)
        {
            currentTime += elapsedTime * timeFactor;
        }
    }
}
